<?php defined('In33hao') or exit('Access Invalid!');?>

<div class="page">
  <div class="fixed-bar">
    <div class="item-title"><a class="back" href="index.php?act=agent&op=index" title="返回代理列表"><i class="fa fa-arrow-circle-o-left"></i></a>
      <div class="subject">
        <h3>商圈代理 - <?php echo $lang['nc_new'];?></h3>
        <h5>商圈代理相关设置和管理</h5>
      </div>
    </div>
  </div>
  <form id="agent_form" enctype="multipart/form-data" method="post">
    <input type="hidden" name="form_submit" value="ok" />
      <input type="hidden" name="province_id" id="_area_1">
      <input type="hidden" name="city_id" id="_area_2">
      <input type="hidden" name="area_id" id="_area_3">
    <div class="ncap-form-default">
        <dl class="row">
            <dt class="tit">
                <label for="store_name"><em>*</em>代理名称</label>
            </dt>
            <dd class="opt">
                <input type="text" value="" id="title" name="title" class="input-txt"/>
                <span class="err"></span>
                <p class="notic"></p>
            </dd>
        </dl>
        <dl class="row">
            <dt class="tit">
                <label for="type"><em>*</em>代理类别</label>
            </dt>
            <dd class="opt">
                <input type="radio" value="2" checked  name="type" id="type1"><label for="type1">市代</label>
                <input type="radio" value="3"  name="type" id="type2"><label for="type2">镇代</label>
                <input type="radio" value="4"  name="type" id="type3"><label for="type3">体验</label>
            </dd>
        </dl>
        <dl class="row">
            <dt class="tit">
                <label for="region"><em>*</em>所属地区</label>
            </dt>
            <dd class="opt">
                <input type="hidden" id="region" name="region"/>
                <span class="err"></span>
                <p class="notic"></p>
            </dd>
        </dl>
        <dl class="row">
            <dt class="tit">
                <label for="member_name"><em>*</em>会员账号</label>
            </dt>
            <dd class="opt">
                <input type="text" value="" id="member_name" name="member_name" class="input-txt" />
                <span class="err"></span>
                <p class="notic">用于登录会员中心</p>
            </dd>
        </dl>
        <dl class="row">
            <dt class="tit">
                <label for="member_points"><em>*</em>积分</label>
            </dt>
            <dd class="opt">
                <input type="text" value="" id="member_points" name="member_points" class="input-txt" />
                <span class="err"></span>
                <p class="notic">用于商城消费，转账等</p>
            </dd>
        </dl>
        <dl class="row">
            <dt class="tit">
                <label for="member_passwd"><em>*</em>登录密码</label>
            </dt>
            <dd class="opt">
                <input type="password" value="" id="member_passwd" name="member_passwd" class="input-txt" />
                <span class="err"></span>
                <p class="notic"></p>
            </dd>
        </dl>
        <dl class="row">
            <dt class="tit">
                <label for="store_name">推荐人</label>
            </dt>
            <dd class="opt">
                <input type="text" value="" id="title" name="invite_agent" class="input-txt"/>
                <span class="err"></span>
                <p class="notic"></p>
            </dd>
        </dl>
      <div class="bot"><a href="JavaScript:void(0);" class="ncap-btn-big ncap-btn-green" id="submitBtn"><?php echo $lang['nc_submit'];?></a></div>
    </div>
  </form>
</div>
<script>
$(function(){

    $("#region").nc_region();

//按钮先执行验证再提交表单    
	$("#submitBtn").click(function(){
		if($("#agent_form").valid()){
			$("#agent_form").submit();
		}
	});
	
//表单验证
	$('#agent_form').validate({
        errorPlacement: function(error, element){
			var error_td = element.parent('dd').children('span.err');
            error_td.append(error);
        },
        rules : {
            title : {
                required : true,
                remote   : {                
                url :'index.php?act=agent&op=check_title',
                type:'get',
                data:{
                    title : function(){
                        return $('#title').val();
                    },
                    type : function(){
                        return $("input[name='type']:checked").val();
                    }
                  }
                }
            },
            region : {
                checklast: true
            },
            member_name: {
                required : true,
                minlength : 3,
                maxlength : 15,
                remote   : {
                    url : 'index.php?act=ownshop&op=check_member_name',
                    type: 'get',
                    data:{
                        member_name : function(){
                            return $('#member_name').val();
                        }
                    }
                }
            },
            member_passwd : {
                required : true,
                minlength: 6
            },
            member_points : {
                required : true,
                digits:true
            },
        },
        messages : {
            title : {
                required : '<i class="fa fa-exclamation-circle"></i>代理名称不能为空',
                remote   : '<i class="fa fa-exclamation-circle"></i>该代理名称已存在'
            },
            member_name: {
                required : '<i class="fa fa-exclamation-circle"></i>请输入会员账号',
                minlength: '<i class="fa fa-exclamation-circle"></i>会员账号最短为3位',
                maxlength: '<i class="fa fa-exclamation-circle"></i>会员账号最长为15位',
                remote   : '<i class="fa fa-exclamation-circle"></i>此名称已被其它店铺会员占用，请重新输入'
            },
            member_passwd : {
                required : '<i class="fa fa-exclamation-circle"></i>请输入登录密码',
                minlength: '<i class="fa fa-exclamation-circle"></i>登录密码长度不能小于6'
            },
            member_points : {
                required : '<i class="fa fa-exclamation-circle"></i>请输入积分值',
                digits: '<i class="fa fa-exclamation-circle"></i>积分必须输入整数'
            }
        }
    });

});
</script> 
